package lab2weight;

/**
 * Title: Weight class for CSIS 235 Lab 2
 * Description: CS 235 Lab #2
 *    Basic class to keep track of the weight of an object in pounds and ounces.
 * 
 * @author Anthony Varghese
 * @email anthony.varghese@my.uwrf.edu
 * @date September 3rd 2014
 * @version 1.0
 */
public class Weight {
	
	/**
	 * Class data members
	 */
	private static final int MAX_OUNCES = 16;
	
	
	/**
	 * Instance data members
	 * No negative weights allowed: neither of these two data members can be less than 0
	 * @classinvariant this.getPounds() >= 0 && this.getPounds() 
	 */
	private int pounds, ounces;

	/**
	 * Default Constructor
	 */
	public Weight(){
		
	}

	/**
	 * Overloaded Constructor
	 */
	public Weight(int lb, int oz){
		pounds = lb;
		ounces = oz;
	}

	/**
	 * toString method
	 * returns a string description of data members
	 */
	public String toString(){
		return "[ " + pounds + " lbs. " + ounces + " oz. ]"; 
	}
	
	
	/**
	 * add method
	 * adds input weight to current weight
	 * @param addedWeight
	 */
	public void add( Weight input ){
		ounces = ounces + input.ounces;
		if (ounces >= MAX_OUNCES){
			pounds = pounds + 1;
			ounces = ounces - MAX_OUNCES;
		}
		pounds = pounds + input.pounds;
	}
	
	
	/**
	 * @return the pounds data member
	 */
	public int getPounds() {
		return pounds;
	}

	/**
	 * @param pnds to set the pounds data member
	 */
	public void setPounds(int lbs) {
		this.pounds = lbs;
	}

	/**
	 * @return the ounces data member
	 */
	public int getOunces() {
		return ounces;
	}

	/**
	 * @param oz to set the ounces data member
	 */
	public void setOunces(int oz) {
		this.ounces = oz;
	}
	
}
